package com.jeff.practice;

import java.util.Scanner;

/**
 * 停车场最少停车问题
 *
 * @author yaojianfeng
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        while (s == null) {
            s = in.nextLine();
        }
        //构建停车场车位数组
        String[] inStrings = s.split(",");
        int[] carPositions = new int[inStrings.length + 1];
        for (int i = 0; i < inStrings.length; i++) {
            carPositions[i] = Integer.parseInt(inStrings[i]);
        }

        while (carPositions.length > 1000) {
            inStrings = in.nextLine().split(",");
            carPositions = new int[inStrings.length + 1];
        }

        //添加终点站
        carPositions[inStrings.length] = 0;
        //统计车辆数
        int count = getCount(carPositions);
        System.out.println(count);
    }

    private static int getCount(int[] carPositions) {
        int count = 0;
        //可停车车位数
        int availableCarPosition = 0;
        for (int carPosition : carPositions) {
            if (carPosition == 1) {
                availableCarPosition++;
            } else if (carPosition == 0) {
                if (availableCarPosition % 3 == 0) {
                    count += availableCarPosition / 3;
                } else {
                    count += availableCarPosition / 3 + 1;
                }
                availableCarPosition = 0;
            }
        }
        return count;
    }
}